<template>
	<view>
		<view class="uni-padding-wrap uni-common-mt">
			<view class="button-sp-area">
				<button v-if="insert" class="mini-btn" type="primary" size="mini" @click="insertMethod()">添加</button>
				<button v-if="detail" class="mini-btn" type="default" size="mini" @click="detailMethod()">详情</button>
				<button v-if="update" class="mini-btn" type="default" size="mini" @click="updateMethod()">修改</button>
				<button v-if="deletes" class="mini-btn" type="warn" size="mini" @click="deletesMethod()">删除</button>
				<button v-if="imports" class="mini-btn" type="primary" size="mini" @click="importsMethod()">导入</button>
			</view>
		</view>
	</view>
</template>

<script>
	// import {
	// 	Reset
	// } from '../../pages/schoollist/controller/index.js'
	// import ajax from '../../myservice/ajaxservice.js'

	export default {
		data() {
			return {}
		},
		props: {
			insert: { //添加
				type: Boolean,
				default: false,
			},
			detail: { //查看详情
				type: Boolean,
				default: false,
			},
			update: { //修改
				type: Boolean,
				default: false,
			},
			deletes: { //删除
				type: Boolean,
				default: false,
			},
			imports: { //导入
				type: Boolean,
				default: false,
			}
		},
		inject: ["Pagination"],
		methods: {
			insertMethod() {
				uni.navigateTo({
					url: 'view/details'
				})
			},
			detailMethod() {//查看详情
				if (this.Pagination.Ids.length < 1) {
					uni.showToast({
						title: '没有选择任何项',
						icon:'none'
					});
					return;
				}
				if (this.Pagination.Ids.length == 1) {
					uni.navigateTo({
						url: 'view/details?detail=' +  this.Pagination.Ids[0] + '&readonly=1'
					})
				}else{
					uni.showToast({
						title: '查看详情只能选择一项',
						icon:'none'
					});
				}
				
			},
			updateMethod() {
				if (this.Pagination.Ids.length < 1) {
					uni.showToast({
						title: '没有选择任何项',
						icon:'none'
					});
					return;
				}

				if (this.Pagination.Ids.length == 1) {
					uni.navigateTo({
						url: 'view/details?detail='+this.Pagination.Ids[0]
					})
				}else{
					uni.navigateTo({
						url: 'view/details?isBatchUpdate=1'
					})
				}

			},
			deletesMethod() {
				var that = this;
				that.Pagination.Deletes = true;
			},
			importsMethod() {
				console.log(this.Pagination.Ids)
			}
		}
	}
</script>

<style>
</style>
